#include "ToneReproductionModel.h"

ToneReproductionModel::ToneReproductionModel(double _Ldmax, double _Lwmax): Ldmax(_Ldmax), Lwmax(_Lwmax){
}

//Gets the average world luminance.
void ToneReproductionModel::calculateLw(vector<MyColor>* pixels){
     double sumOfLogs = 0;
     for(size_t i = 0; i < pixels->size(); i++){
          sumOfLogs += log(EPSILON+getLuminance(pixels->at(i)));
     }
     Lw = exp(sumOfLogs/(pixels->size()));
}

double ToneReproductionModel::getLuminance(MyColor c){
     double Rxy = c.r * Ldmax;
     double Gxy = c.g * Ldmax;
     double Bxy = c.b * Ldmax;
     return 0.27*Rxy+0.67*Gxy+0.06*Bxy;
}